package com.zc.iotDevice.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.iotDevice.mapper.ChargeFaultMapper;
import com.zc.iotDevice.domain.ChargeFault;
import com.zc.iotDevice.service.IChargeFaultService;

/**
 * 故障报修Service业务层处理
 *
 * @author glb
 * @date 2023-08-28
 */
@Service
public class ChargeFaultServiceImpl implements IChargeFaultService
{
    @Autowired
    private ChargeFaultMapper chargeFaultMapper;

    /**
     * 查询故障报修
     *
     * @param deviceFaultId 故障报修主键
     * @return 故障报修
     */
    @Override
    public ChargeFault selectChargeFaultByDeviceFaultId(Long deviceFaultId)
    {
        return chargeFaultMapper.selectChargeFaultByDeviceFaultId(deviceFaultId);
    }

    /**
     * 查询故障报修列表
     *
     * @param chargeFault 故障报修
     * @return 故障报修
     */
    @Override
    public List<ChargeFault> selectChargeFaultList(ChargeFault chargeFault)
    {
        return chargeFaultMapper.selectChargeFaultList(chargeFault);
    }

    /**
     * 新增故障报修
     *
     * @param chargeFault 故障报修
     * @return 结果
     */
    @Override
    public int insertChargeFault(ChargeFault chargeFault)
    {
        chargeFault.setCreateTime(DateUtils.getNowDate());
        return chargeFaultMapper.insertChargeFault(chargeFault);
    }

    /**
     * 修改故障报修
     *
     * @param chargeFault 故障报修
     * @return 结果
     */
    @Override
    public int updateChargeFault(ChargeFault chargeFault)
    {
        if("1".equals(chargeFault.getHandleStatus())){
            chargeFault.setHandleTime(DateUtils.getNowDate());
        }
        return chargeFaultMapper.updateChargeFault(chargeFault);
    }

    /**
     * 批量删除故障报修
     *
     * @param deviceFaultIds 需要删除的故障报修主键
     * @return 结果
     */
    @Override
    public int deleteChargeFaultByDeviceFaultIds(Long[] deviceFaultIds)
    {
        return chargeFaultMapper.deleteChargeFaultByDeviceFaultIds(deviceFaultIds);
    }

    /**
     * 删除故障报修信息
     *
     * @param deviceFaultId 故障报修主键
     * @return 结果
     */
    @Override
    public int deleteChargeFaultByDeviceFaultId(Long deviceFaultId)
    {
        return chargeFaultMapper.deleteChargeFaultByDeviceFaultId(deviceFaultId);
    }
}
